import spacy

# Load the transformer-based model
nlp = spacy.load("en_core_web_trf")

# Input text
text = "Elon Musk announced that Tesla is opening a new factory in Berlin next year."

# Process the text
doc = nlp(text)

# Extract and display named entities
print("Named Entities:")
for ent in doc.ents:
    print(f"{ent.text} - {ent.label_}")
